package com.bwie.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import com.bwie.common.ServiceMessage;
import com.bwie.pojo.Goods;
import com.bwie.service.GoodsService;

@RestController
public class GoodsController {

	@Autowired
	private GoodsService goodsService;
	
	@GetMapping("/{pid}")
	public ServiceMessage getChildrenByPid(@PathVariable long pid) {
		try {
			List<Goods> list = goodsService.getBypid(pid);
			return ServiceMessage.ok(list);
		} catch (Exception e) {
			e.printStackTrace();
			return ServiceMessage.error();
		}
	
	}
	
}
